package heman.common;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
/**
 * 
 * This helps to generate the XML string from a XML node
 * 
 * @author Wenlong Liu
 *
 */
public class XMLConverter {
	public static String convertGameState(Node node){
		if (node==null) return "";
		/**
		 * <gameState player="85" score="10"/>
		 */
		StringBuilder sb=new StringBuilder("<gameState player=\"");
		NamedNodeMap map = node.getAttributes();
		Node pname = map.getNamedItem("player");
		sb.append(pname.getNodeValue()+"\" score=\""+
				map.getNamedItem("score").getNodeValue()+"\"/>");
		
		
		return sb.toString();
	}

}
